﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AuthorityMenuEdit.aspx.cs" Inherits="_2010web.Manage.authority.AuthorityMenuEdit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
     <!-- #include file="~/html/file.aspx" -->
</head>
<body>
    <form id="form1" runat="server">
        <div class="alert_info">
            <div class="alert_form" id="info">
                <ul>
                    <li><b style="font-weight: 400">父级：</b><div>
                        <asp:DropDownList runat="server" ID="ddParentRole">
                        </asp:DropDownList>
                    </div>
                    </li>
                    <li><b style="font-weight: 400">名称：</b><div>
                        <asp:TextBox CssClass="inputtxt w180" runat="server" MaxLength="16" ID="txtName" />
                    </div>
                    </li>
                    <li><b style="font-weight: 400">URL：</b><div>
                        <asp:TextBox CssClass="inputtxt" Width="300" runat="server" ID="txtURL" />
                    </div>
                    </li>
                     <li><b style="font-weight: 400">代码：</b><div>
                        <asp:TextBox CssClass="inputtxt w180" runat="server" MaxLength="16" ID="txtMenuCode" />
                    </div>
                    </li>
                    <li><b style="font-weight: 400">排序：</b><div>
                        <asp:TextBox CssClass="inputtxt w180" runat="server" MaxLength="16" ID="txtOrderNum" />
                    </div>
                    </li>
                </ul>
                <div class="btns">
                    <a href="javascript:void(0);" class="submit">
                        <input type="button" value="确认" onclick="Save();" />
                        </a><a href="#" onclick="return false;" class="cancel">
                                <input type="button" value="取消" onclick="parent._M.CallBack('_M.CloseIframe()');" /></a>
                   <span style="display:none"><asp:Button runat="server" ID="btnSave" OnClick="btnSave_Click" /></span>
                </div>
            </div>
        </div>

        <script language="javascript" type="text/javascript">
            function Save() {
                var reg = /^[0-9]{0,12}$/;
                if ($.trim($("#txtName").val()) == "") {
                    _M.ErrorMsg(null, '菜单名称不能为空！', 'info');
                    return ;
                }
                if ($.trim($("#txtURL").val()) == "") {
                    _M.ErrorMsg(null, 'URL不能为空！', 'info');
                    return ;
                }
                if ($.trim($("#txtMenuCode").val()) == "") {
                    _M.ErrorMsg(null, '代码不能为空！', 'info');
                    return ;
                }
                if ($.trim($("#txtMenuCode").val()).match(reg) == null) {
                    _M.ErrorMsg(null, '代码只能是数字！', 'info');
                    return ;
                }
                if ($.trim($("#txtOrderNum").val()) == "") {
                    _M.ErrorMsg(null, '排序不能为空！', 'info');
                    return ;
                }
                
                if ($.trim($("#txtOrderNum").val()).match(reg)==null)
                {
                    _M.ErrorMsg(null, '排序只能是数字！', 'info');
                    return ;
                }
               
                var menucode = $.trim($("#txtMenuCode").val());
                $.ajax({
                    type: "POST",
                    url: "../ajax/api.aspx",
                    dataType: "json",
                    data: {
                        action: "checkCode",
                        code: menucode,
                        menuId:<%=intID%>,
                    },
                    success: function (response) {
                        if (!response.IsError) {
                            $("#btnSave").click();
                        } else {
                            _M.ErrorMsg(null, '代码重复！', 'info');
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {

                    },
                    complete: function (XHR, TS) {
                       
                    }
                });
            }
            <%=strMessage %>
        </script>
    </form>
</body>
</html>
